#include "players.h"
#include "units.h"



player::player( int i, string n, PlayerType t )
{
	id = i;
	name = n;
	typ = t;
	time = parameters::get_instance()->game_parameters[ "START_TIME" ];
	in_game = true;
};



player::~player()
{
	for( unsigned int i = 0; i < units.size(); ++i )
	{
		delete units[ i ];
	}
	units.clear();
};



player* player::clone()
{
	player* p = new player( id, name, typ );
	p->set_time( time );
	for( unsigned int i = 0; i < units.size(); ++i )
	{
		unit* cu = dynamic_cast< unit* >( units[ i ]->clone() );
		cu->set_player( p );
		p->units.push_back( cu );
	}
	p->ai_algorithm = ai_algorithm;
	return p;
};